package com.six.shop.controller.api;

import com.google.j2objc.annotations.AutoreleasePool;
import com.six.core.entity.CheckShop;
import com.six.core.entity.Shop;
import com.six.core.vo.Result;
import com.six.shop.service.CheckShopService;
import com.six.shop.service.ShopService;
import com.six.shop.vo.SearchShop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName:ApIShopContriller
 * Description:
 * date:2023/2/27 10:17
 *
 * @since JDK 1.8
 */
@Api(value = "shop/api/shop", tags = {"ClassName:ApIShopContriller Description: date:2023/2/27 10:17"})
@RestController
@RequestMapping("shop/api/shop")
public class ApIShopContriller {
    @Autowired
    private ShopService shopService;


    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "", required = true),
            @ApiImplicitParam(paramType = "body", dataType = "SearchShop", name = "shop", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @PostMapping("findAll")
    public Result findAll( @RequestParam(defaultValue = "1") Integer currentPage, @RequestParam(defaultValue = "5")Integer pageSize,@RequestBody SearchShop shop){
        return shopService.findAll(shop,currentPage,pageSize);
    }
    @ApiOperation(value = "", notes = "", httpMethod = "GET")
    @GetMapping("findAllShop")
    public Result findAllShop(){
        return shopService.findAllShop();
    }
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Shop", name = "shop", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @PostMapping("updateStateFales")
    public Result updateStateFales(@RequestBody Shop shop) {
        return shopService.UpdateStateFales(shop);
    }


    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "userid", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "GET")
    @GetMapping("/getShopId")
    public Integer getShopId(Integer userid){
        return shopService.getShopId(userid);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Shop", name = "shop", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @PostMapping("insertShop")
    public Result insertShop(@RequestBody Shop shop){
        return shopService.insertShop(shop);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Shop", name = "shop", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @PostMapping("/add")
    public Integer add(@RequestBody Shop shop){
        return shopService.add(shop);
    }
}
